//
//  TestView.swift
//  SwitfTest
//
//  Created by runone02 on 2018/12/27.
//  Copyright © 2018年 liqiyun. All rights reserved.
//

import UIKit


class TestView: UIView {

        //初始化
        override init(frame: CGRect) {
            super.init(frame: frame)
            //设置背景为灰色
            self.backgroundColor = UIColor.gray
        }
        //自动布局
        override func layoutSubviews() {
            //设置view的大小和位置

            let btn = UIButton(type:.custom)
            btn.backgroundColor = UIColor.black
            btn.addTarget(self, action: #selector(btnClick), for: .touchUpInside)
     
            self.addSubview(btn)
            btn.mas_makeConstraints { (make) in
                make?.centerY.mas_equalTo()(self)
                make?.centerX.mas_equalTo()(self)
                make?.width.mas_equalTo()(50)
                make?.height.mas_equalTo()(50)
            }
            
        }
        required init?(coder aDecoder: NSCoder) {
            fatalError("init(coder:) has not been implemented")
        }

    @objc func btnClick(){
      
    }


    
}
